﻿
 function AskControl()
 {
   var app;
   var url;
   var appUrl;
 };
 AskControl.prototype.ini = function()
 {
   this.app='ask';
   this.url='index.php';
   this.appUrl=this.url+'?app='+this.app;
 };
 AskControl.prototype.messageBox = function(title,content)
 {
 }
 //-------------------------------------------
 //跳转
 //-------------------------------------------
 AskControl.prototype.toUrl = function(url)
 {
	window.location.href=url;
 };
 //-------------------------------------------
 //关闭窗口
 //-------------------------------------------
 AskControl.prototype.closeWindow = function(id)
 {
	$('#'+id).remove();
 };
 
  AskControl.prototype.hideWindow = function(id)
 {
	$('#'+id).css('display','none');
 };
 //-------------------------------------------
 //获取滚动条高度
 //-------------------------------------------
 AskControl.prototype.getScrollTop = function()
 {
    var scrollTop=0;
    if(document.documentElement&&document.documentElement.scrollTop)
    {
        scrollTop=document.documentElement.scrollTop;
    }
    else if(document.body)
    {
        scrollTop=document.body.scrollTop;
    }
    return scrollTop;
 }
 //-------------------------------------------
 //退出
 //-------------------------------------------
 AskControl.prototype.logout = function()
 {
	if(confirm("确定要退出？"))
	{
		this.toUrl(__ask.appUrl+'&c=index&ac=logout');
	}
	else
	{
		return false;
	}
 }
 //-------------------------------------------
 //登录
 //-------------------------------------------
 AskControl.prototype.login = function()
 {
	//window.location.href="http://localhost/passport/index.php?c=xml&product=1";
	var username=$('#username').val();
	var password=$('#password').val();
	username=trim(username);
	password=trim(password);
	
	var Days = 30;  
    var exp = new Date();   
    exp.setTime(exp.getTime() + Days*24*60*60*1000);  	
	if(username==''||password==''){__ask.alert('alert','警告','账号/密码不能为空','');return false;}	
	$.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'index',ac:'login',username:username,password:password},
		   success:function(echo){
                       document.cookie="account="+username+ ";expires=" + exp.toGMTString();
                       //document.cookie="password="+password+ ";expires=" + exp.toGMTString();
                       __ask.toUrl(echo);},
		   error:function(){}
		   }) 
 }
 
  AskControl.prototype.one_key_login = function()
 {
	//window.location.href="http://localhost/passport/index.php?c=xml&product=1";
	$.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'index',ac:'one_key_login'},
		   success:function(echo){
                       __ask.toUrl(echo);},
		   error:function(){}
		   }) 
 }
 AskControl.prototype.select_dog = function()
 {
	//window.location.href="http://localhost/passport/index.php?c=xml&product=1";
	var key ='';
	key= $('#dog_select').val();
	$.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'index',ac:'receive_dog',receive:key},
		   success:function(echo){$('body').html(echo)},
		   error:function(){}
		   }) 
 }
 
 function getCookie(name)  
{  
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");  
if(arr=document.cookie.match(reg)) return unescape(arr[2]);  
else return null;  
}  
 //-------------------------------------------
//回车登录
//-------------------------------------------
 AskControl.prototype.enterLogin =function(evt)
 {  
	evt = (evt) ? evt : ((window.event) ? window.event : "") 
	keyCode = evt.keyCode ? evt.keyCode : (evt.which ? evt.which : evt.charCode); 
	if (keyCode == 13) { 
            this.login();  
	}   
 }
 
//-------------------------------------------
//点击更多用户信息
//-------------------------------------------
 AskControl.prototype.more_user_info =function()
 {
	 document.cookie="user_info=more";
	 $('#more_user_info').css('display','none');
	 $('#user_info_ask').css('display','block');
	 //$('#user_info').css('height','250px');
	 //$('#account_set').css('display','none');
 }
//-------------------------------------------
//收起更多用户信息
//-------------------------------------------
 AskControl.prototype.less_user_info =function()
 {
	 document.cookie="user_info=less";
	 $('#more_user_info').css('display','block');
	 $('#user_info_ask').css('display','none');
	 //$('#user_info').css('height','150px');
	 //$('#account_set').css('display','block');
 }

 AskControl.prototype.less_service_info=function()
 {
	 document.cookie="service_info=less";
	 $('#promise').slideToggle("slow"); 	 
	 $('#service_less').css('display','none');
	 $('#service_more').css('display','block');
	 }
	 
AskControl.prototype.more_service_info=function()
 {
	 document.cookie="service_info=more";
	 $('#promise').slideToggle("slow"); 	 
	 $('#service_more').css('display','none');
	 $('#service_less').css('display','block');
	 }
AskControl.prototype.less_friend_info=function()
 {
	 document.cookie="friend_info=less";
	 $('#friend_links').slideToggle("slow"); 
	 $('#friend_less').css('display','none');
	 $('#friend_more').css('display','block');
	 }
	 
AskControl.prototype.more_friend_info=function()
 {
	 document.cookie="friend_info=more";
	 $('#friend_links').slideToggle("slow"); 
	 $('#friend_more').css('display','none');
	 $('#friend_less').css('display','block');
	 }

AskControl.prototype.show_category=function()
 {
	$('.category_none').css('display','');
	$('#hidden_category').css('display','');
	$('#show_category').css('display','none');
}

AskControl.prototype.hidden_category=function()
 {
	$('.category_none').css('display','none');
	$('#hidden_category').css('display','none');
	$('#show_category').css('display','');
}

AskControl.prototype.show_brand=function()
 {
		$('.brand_none').css('display','');
	$('#hidden_brand').css('display','');
	$('#show_brand').css('display','none');
}

AskControl.prototype.hidden_brand=function()
 {
	$('.brand_none').css('display','none');
	$('#hidden_brand').css('display','none');
	$('#show_brand').css('display','');
}	

 
 AskControl.prototype.search_content_detail =function()
 {  
	var str=$('#search_content_detail_material').val()+$('#search_content_detail_brand').val()
	+$('#search_content_detail_supplier').val();
	
 }
  //-------------------------------------------
//回车搜索
//-------------------------------------------
 AskControl.prototype.enterSearch =function(evt)
 {  
	evt = (evt) ? evt : ((window.event) ? window.event : "") 
	keyCode = evt.keyCode ? evt.keyCode : (evt.which ? evt.which : evt.charCode); 
	if (keyCode == 13) { 
            this.fast_search('content');  
	}   
 }
 
 
  AskControl.prototype.entertopSearch =function(evt)
 {  
	evt = (evt) ? evt : ((window.event) ? window.event : "") 
	keyCode = evt.keyCode ? evt.keyCode : (evt.which ? evt.which : evt.charCode); 
	if (keyCode == 13) { 
            this.fast_search('key_other_page');  
	}   
 }

  AskControl.prototype.enterkeySearch =function(evt)
 {  
	evt = (evt) ? evt : ((window.event) ? window.event : "") 
	keyCode = evt.keyCode ? evt.keyCode : (evt.which ? evt.which : evt.charCode); 
	if (keyCode == 13) { 
            this.fast_search('key');  
	}   
 }
 //-------------------------------------------
 //插入用户意见
 //-------------------------------------------
 AskControl.prototype.submit_advise = function()
 {
	 var message_title=$('#message_title').val();
	 var message_content=$('#message_content').val();
	 message_title=trim(message_title);
	 message_content=trim(message_content);
	 if(message_title==''||message_content==''){__ask.alert('alert','警告','意见反馈 标题/内容不能为空');return false;}
	 if(message_title.length<3||message_content.length<3){__ask.alert('alert','警告','意见反馈 标题/内容长度过短');return false;}	
	 $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'home',ac:'save_advise',message_title:message_title,message_content:message_content},
		   success:function(echo){
			   				      if(echo.indexOf('页面已经过期')>=0)
								 {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
								 }
								 else if(echo.indexOf('异地登录')>=0)
								 {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
								 }
			                     else if(echo=="success_submit")
								 {
									   __ask.alert('ok','提示','意见发布成功','__ask.toUrl("'+__ask.appUrl+'&c=message&ac=messagebox_outbox");');
								  }
								 else
								  {
									   __ask.alert('alert','警告','参数错误','');
								  }
			   },
		   error:function(){}
		   }) 
 }
 
 //-------------------------------------------
 //插入用户投诉
 //-------------------------------------------
 AskControl.prototype.submit_complaint = function()
 {
	 var complaint_title=$('#complaint_title').val();
	 var complaint_content=$('#complaint_content').val();
	 complaint_title=trim(complaint_title);
	 complaint_content=trim(complaint_content);
	 if(complaint_title==''||complaint_content==''){__ask.alert('alert','警告','投诉 标题/内容不能为空');return false;}	
	 $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'home',ac:'save_complaint',complaint_title:complaint_title,complaint_content:complaint_content},
		   success:function(echo){
			   				       if(echo.indexOf('页面已经过期')>=0)
									{
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									}
								   else if(echo.indexOf('异地登录')>=0)
								    {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									 }
			                       else if(echo=="success_submit")
								   {
									   __ask.alert('ok','提示','投诉发布成功','__ask.toUrl("'+__ask.appUrl+'&c=message&ac=messagebox_outbox");');
								   }
								   else
								   {
									   __ask.alert('alert','警告','参数错误','');
								   }
			   },
		   error:function(){}
		   }) 
 }
 
 AskControl.prototype.fast_search_insert = function(content)
 {
	 $('#category_search').val('');
	  $('#brand_search').val('');
      $('#search_content_key').val(content);
	  __ask.fast_search('content');
 }
 

 
 //-------------------------------------------
 //快速查询
 //-------------------------------------------
 AskControl.prototype.fast_search = function(type)
 {
	
	 __ask.closeWindow('mask3');
	 __ask.closeWindow('mask3in');
	 var search_str=trim($('#search_key').val());
	 
	 $('#asklist_tab').css("display","block");
	 if(type=='key_other_page')
	 { __ask.creat_mask('mask3');
		 $('#category_search').val('');
	  $('#brand_search').val('');
	  
		 if(search_str==''){__ask.alert('alert','警告','请输入查询内容');return false;}
		 $.ajax({
			   type: "POST",
			   url:this.url,
			   data:{app:this.app,c:'search',ac:'index'},
			   success:function(echo){
				                       if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else
									   {
				   							$('body').html(echo);
				   							document.getElementById('search_content_key').value=search_str;
				   							__ask.fast_search('content');
				   						}
				   						},
			   error:function(){}
			   }) ;
	 }
	 else if(type=='key')
	 {
		  $('#category_search').val('');
	  $('#brand_search').val('');
		 if(search_str==''){__ask.alert('alert','警告','请输入查询内容');return false;}
		 document.getElementById('search_content_key').value=search_str;
	     $('#search_result').html("<img src='./app_ask/view/images/loader.gif' class='loader' />");
									   $('#search_result').css('display','block');
		 $.ajax({
			   type: "POST",
			   url:this.url,
			   data:{app:this.app,c:'search',ac:'fast_search',search_content_key:search_str},
			   success:function(echo){
				                       if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else
									   {
									       $('#search_result').html(echo); $('#search_content_detail_material').val($('#search_str').val());
									   }
									   },
			   error:function(){}
			   }) ;
	 }
	 else if(type=='content')
	 {
		  $('#category_search').val('');
	  $('#brand_search').val('');
	
	  $('#search_content_detail_material').val($('#search_content_key').val());
	
		 var search_content_key=trim($('#search_content_detail_material').val());
	
	     if(search_content_key==''){__ask.alert('alert','警告','请输入查询内容');return false;}
	     $('#search_result').html("<img src='./app_ask/view/images/loader.gif' class='loader' />");
									   $('#search_result').css('display','block');
		 $.ajax({
			   type: "POST",
			   url:this.url,
			   data:{app:this.app,c:'search',ac:'fast_search',search_content_key:search_content_key},
			   success:function(echo){
				                       if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else
									   {
										
									       $('#search_result').html(echo);
										    $('#search_content_detail_material').val('');
	                                        $('#search_content_detail_brand').val('');
	                                        $('#search_content_detail_supplier').val('');
										   $('#search_content_detail_material').val($('#search_content_key').val());
										   
									   }
									   },
			   error:function(){}
			   }) ;
	 }
	  else if(type=='detail')
	 {
		var category_search=$('#category_search').val();
	    var brand_search=$('#brand_search').val();
		 var search_content_key=trim($('#search_content_key').val());
	     if(search_content_key==''){__ask.alert('alert','警告','请输入查询内容');return false;}
	     $('#ask_search_detail').html("<img src='./app_ask/view/images/loader.gif' class='loader' />");
									   $('#search_result').css('display','block');
		 $.ajax({
			   type: "POST",
			   url:this.url,
			   data:{app:this.app,c:'search',ac:'fast_search',search_content_key:search_content_key,category_search:category_search,brand_search:brand_search},
			   success:function(echo){
				                       if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else
									   {
									       $('#ask_search_detail').html(echo);
									   }
									   },
			   error:function(){}
			   }) ;
	 }
	 else if(type=='search_content_detail')
	 {
		  $('#category_search').val('');
	  $('#brand_search').val('');
	  var material_temp=$('#search_content_detail_material').val();
	  var brand_temp=$('#search_content_detail_brand').val();
	  var supplier_temp=$('#search_content_detail_supplier').val();
	 
		 var search_content_key=trim(material_temp+brand_temp+supplier_temp);
		 
	     if(search_content_key==''){__ask.alert('alert','警告','请输入查询内容');return false;}
	     $('#search_result').html("<img src='./app_ask/view/images/loader.gif' class='loader' />");
									   $('#search_result').css('display','block');
		 $.ajax({
			   type: "POST",
			   url:this.url,
			   data:{app:this.app,c:'search',ac:'fast_search',search_content_key:search_content_key},
			   success:function(echo){
				                       if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else
									   {
									       $('#search_result').html(echo);
										   $('#search_content_detail_material').val(material_temp);
										   $('#search_content_detail_brand').val(brand_temp);
										   $('#search_content_detail_supplier').val(supplier_temp);
									   }
									   },
			   error:function(){}
			   }) ;
	 }
 }
 

   //询价排序
  AskControl.prototype.search_order = function(str)
 {
	 var order_num=0;
	 var order_old=$('#search_order').val();
	
   switch(str)
   {
	   case "price":
	   	 			if(order_old==3)
					{order_num=4;}
					else if(order_old==4)
					{order_num=3;}
					else
					{
						order_num=3;
					}
					$('#search_order').val(order_num);
	   				break;
	   case "dateline":
	   					if(order_old==1)
					{order_num=2;}
					else if(order_old==1)
					{order_num=2;}
					else
					{
						order_num=1;
					}
					$('#search_order').val(order_num);
	   					break;
	   case "default": order_num=0;$('#search_order').val(order_num);break
	   
	}
	
	
  $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'search',ac:'search_order',order_num:order_num},
		   success:function(){__ask.fast_search('detail');},
		   error:function(){}
		   }) 
	
 }
 
 
 
  AskControl.prototype.no_brand = function()
 {
        $('.brand_color').css('background-color','');
	$('.brand_color').css('color','');
	$('#brand_search').val('');
	$('#brand_no').css('background-color','#39F');
	$('#brand_no').css('color','#FFF');
	__ask.fast_search('detail');
 }
 
   AskControl.prototype.no_category = function()
 {
	$('.category_color').css('background-color','');
	$('.category_color').css('color','');
	$('#category_no').css('background-color','#39F');
	$('#category_no').css('color','#FFF');
	$('#category_search').val('');
	__ask.fast_search('detail');
 }
 
  AskControl.prototype.search_category_detail = function(category_id)
 {
	 $('.category_color').css('color','');
	   $('.category_color').css('background-color','');
	    $('#category_no').css('background-color','');
	  $('#category_no').css('color','');
	  $('#category_'+category_id).css('background-color','#39F');
	  $('#category_'+category_id).css('color','#FFF');
	$('#category_search').val(category_id);
	 __ask.fast_search('detail');
 }
 
   AskControl.prototype.search_brand_detail = function(brand,id)
 {
	 $('.brand_color').css('color','');
	 $('.brand_color').css('background-color','');
	  $('#brand_no').css('background-color','');
	  $('#brand_no').css('color','');
	 $('#brand_'+id).css('background-color','#39F');
	  $('#brand_'+id).css('color','#FFF');
	$('#brand_search').val(brand);
	 __ask.fast_search('detail');
 }
 
 
  AskControl.prototype.supplier_info = function(supplier_name,contact,tel,addr,remarks)
 {
	 __ask.alert('ok',supplier_name,'<br /><div id="supplier_info"><ul><li>联系人&nbsp;:&nbsp;</li><li>'+contact+'</li></ul><ul><li>电&nbsp;&nbsp;&nbsp;话&nbsp;:&nbsp;</li><li>'+tel+'</li></ul><ul><li>地&nbsp;&nbsp;&nbsp;址&nbsp;:&nbsp;</li><li>'+addr+'</li></ul><ul><li>备&nbsp;&nbsp;&nbsp;注&nbsp;:&nbsp;</li><li>'+remarks+'</li></ul></div>','',400,300);
 }
 
 //-------------------------------------------
 //收集用户询价信息
 //-------------------------------------------
 AskControl.prototype.gatherask = function()
 {
	 var ask=$("input[id*=ask_]");
	 var ask_num_now=ask.length;
	 var arr=new Array();
	 var temp=new Array();
	 for(var i=1;i<=ask_num_now;i++)
	 {
		 var ask_content=trim($('#ask_'+i).val());
		 if(ask_content=="") continue;
		 var temp={'ask_content':ask_content}
	     arr.push(temp);
	 }
	 return arr;
 }
 //-------------------------------------------
 //我要询价
 //-------------------------------------------
 AskControl.prototype.submit_ask2 = function()
 {
	 $('#pop_window_submit').css('display','none');
	 $('#pop_window_back').css('display','none'); 
	 $('#pop_window_loading').css('display','');
	 $('#askname').attr('disabled','disabled');
	 $('#askmobile').attr('disabled','disabled');
	 $('#askcompany').attr('disabled','disabled');
	 $('#allow_receive').attr('disabled','disabled');
	 var askname=trim($('#askname').val());
	 var askmobile=trim($('#askmobile').val());
	 var askcompany=trim($('#askcompany').val());
	 var allow_receive=0;
	 if($('#allow_receive').attr('checked')) allow_receive=1;
	 
	 var asktitle=$('#ask_title').text();
	 
	 var askarea=$('#askarea').val();
	 var asktype=$('#asktype').val();

	 var service_id;
	 $("input[type=radio][name=service_id]").each(function(){
			if(this.checked)
			service_id = this.value; 
	 });
	 
	 var project_name=trim($('#project_name').val());
	 var project_addr=trim($('#project_addr').val());
	 var project_process=$('#project_process').val();
	 var project_jiafang=trim($('#project_jiafang').val());
	 var project_shejiyuan=trim($('#project_shejiyuan').val());
	 var project_anzhuang=trim($('#project_anzhuang').val());
	 var attach_id='';
	 attach_id=$('#attach_id').val();
	 var has_attachment=false;
	 if(attach_id==""){has_attachment=false;}
	 else {has_attachment=true;}
	 if(askname==''||askmobile==''||askcompany==''){__ask.alert('alert','警告','姓名/手机/公司名称不能为空');
	 												$('#pop_window_submit').css('display','');
	 												$('#pop_window_back').css('display',''); 
	 								  				$('#pop_window_loading').css('display','none');
													$('#askname').attr('disabled','');
	 												$('#askmobile').attr('disabled','');
	 												$('#askcompany').attr('disabled','');
	 												$('#allow_receive').attr('disabled','');
													return false;}
	 if(askname.length<2) {__ask.alert('alert','警告','请填写正确的姓名');
	 												$('#pop_window_submit').css('display','');
	 												$('#pop_window_back').css('display',''); 
	 								  				$('#pop_window_loading').css('display','none');
													$('#askname').attr('disabled','');
	 												$('#askmobile').attr('disabled','');
	 												$('#askcompany').attr('disabled','');
	 												$('#allow_receive').attr('disabled','');
													return false;}
	 if(!__reguler.is_mobile(askmobile)) {__ask.alert('alert','警告','请填写正确的11位手机号码');
	 												$('#pop_window_submit').css('display','');
	 												$('#pop_window_back').css('display',''); 
	 								  				$('#pop_window_loading').css('display','none');
													$('#askname').attr('disabled','');
	 												$('#askmobile').attr('disabled','');
	 												$('#askcompany').attr('disabled','');
	 												$('#allow_receive').attr('disabled','');
													return false;}
	 if(askcompany.length<2) {__ask.alert('alert','警告','请填写正确的公司名');
	 												$('#pop_window_submit').css('display','');
	 												$('#pop_window_back').css('display',''); 
	 								  				$('#pop_window_loading').css('display','none');
													$('#askname').attr('disabled','');
	 												$('#askmobile').attr('disabled','');
	 												$('#askcompany').attr('disabled','');
	 												$('#allow_receive').attr('disabled','');
													return false;}
	 var arr=this.gatherask();
	 if(arr.length<1)
	 {
		 __ask.alert('alert','警告','没有输入询价信息');
		 $('#pop_window_submit').css('display','');
	 	$('#pop_window_back').css('display',''); 
		  $('#pop_window_loading').css('display','none');
		  $('#askname').attr('disabled','');
		$('#askmobile').attr('disabled','');
		$('#askcompany').attr('disabled','');
		$('#allow_receive').attr('disabled','');
		 return false;
	 }
	 var json_str=$.toJSON(arr); 
	 this.creat_mask('mask');
	 $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'ask',ac:'save_ask_info',
		         askname:askname,askmobile:askmobile,askcompany:askcompany,allow_receive:allow_receive,
				 asktitle:asktitle,askarea:askarea,asktype:asktype,attach_id:attach_id,service_id:service_id,
				 project_name:project_name,project_addr:project_addr,project_process:project_process,
				 project_jiafang:project_jiafang,project_shejiyuan:project_shejiyuan,has_attachment:has_attachment,
				 project_anzhuang:project_anzhuang,arr:json_str},
		   success:function(echo){
			                          __ask.closeWindow("mask");
								       if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
			   						     $('#pop_window_submit').css('display','');
	 									 $('#pop_window_back').css('display',''); 
	 								     $('#pop_window_loading').css('display','none');
										  $('#askname').attr('disabled','');
										$('#askmobile').attr('disabled','');
										$('#askcompany').attr('disabled','');
										$('#allow_receive').attr('disabled','');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
			   						     $('#pop_window_submit').css('display','');
	 									 $('#pop_window_back').css('display',''); 
	 								     $('#pop_window_loading').css('display','none');
										  $('#askname').attr('disabled','');
										$('#askmobile').attr('disabled','');
										$('#askcompany').attr('disabled','');
										$('#allow_receive').attr('disabled','');
									   }
									   if(echo=='success')
									   {
										   __ask.alert('ok','询价成功','您的询价请求已发布成功!<br/>如需帮助请您致电询价客服热线: <br />021-65377007*8007<br /><span style=\'padding-left:100px;\'>信息中心</span>','__ask.toUrl("'+__ask.appUrl+'&c=ask&ac=myask");','','220');
										   
									   }
									   else
									   {
										   __ask.alert('alert','错误',echo);
			   						     $('#pop_window_submit').css('display','');
	 									 $('#pop_window_back').css('display',''); 
	 								     $('#pop_window_loading').css('display','none');
										  $('#askname').attr('disabled','');
										$('#askmobile').attr('disabled','');
										$('#askcompany').attr('disabled','');
										$('#allow_receive').attr('disabled','');
									   }
								  },
		   error:function(){}
		   }) 
		   
 }
 
AskControl.prototype.upload_show = function()
{
	if(document.getElementById('div_upload').style.display=='block')
	{
		$('#div_upload').css('display','none');
		}
	else
	{
		$('#div_upload').css('display','block')
		}
}

AskControl.prototype.upload_del = function()
{
	var attach_id=$('#attach_id').val();
	if(confirm("确定删除该文件？"))
	{
	$.ajax({
			   type: "POST",
			   url:this.url,
			   data:{app:this.app,c:'ask',ac:'del_upload',attach_id:attach_id},
			   success:function(echo){
				   					   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo=='succeed')
										{
											__ask.alert('alert','提示','操作成功');
											$('#upload_show').css('display','');
											$('#upload_del').css('display','none');
											document.getElementById('attach_id').value='';
											$('#attachment').text('未上传附件');
										}
										else
										{
											__ask.alert('alert','错误','操作失败');
										}
									   },
			   error:function(){}
			   }) ;
	}

}
 
//上传文件
AskControl.prototype.import_upload = function()
{
	if($('#FILE_UPLOAD').val()=="")
	{
		__ask.alert('alert','提示','请选择上传文件');
		return false;
	}
	if(confirm("确定上传该文件？"))
	{
		$('#dealing').css('display','block');
		$('#div_upload').css('display','none');
		$.ajaxFileUpload
		(
			{
				url:'upload.php',
				//url:this.url,
				secureuri:false,
				fileElementId:'FILE_UPLOAD',
				dataType: 'json',
				//data:{app:this.app,c:'upload',ac:'uploadx'},
				
				success: function (data, status)
				{ 	
					if(data.type=='login_again')
				   {
					   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
				   }
				   else if(data.type=='another_login')
				   {
					   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
				   }
					else if(typeof(data.error) != 'undefined')
					{
						if(data.error != '')
						{
							__ask.alert('alert','错误',data.error);
							$('#div_upload').css('display','block');
						}
						else
						{
							__ask.alert('alert','提示','上传成功');
							$('#attachment').text(data.filename);
							$('#div_upload').css('display','none');
							$('#upload_show').css('display','none');
							$('#upload_del').css('display','');
							document.getElementById('attach_id').value=data.attach_id;
							//$('<option>'+data.filename+'</option>').appendTo('#attachment')
						}
						
					}
					$('#dealing').css('display','none');
				},
				error: function (data, status)
				{
					__ask.alert('alert','错误','e');
					$('#dealing').css('display','none');
					$('#div_upload').css('display','block');
				}
			}
		)
	}
	else
	{
		return false;
	}
}

 //-------------------------------------------
 //创造mask遮罩
 //-------------------------------------------
 AskControl.prototype.creat_mask = function(mask)
 {
	 if(mask!='mask3')
	 {
		$('body').append('<div id="'+mask+'"><iframe></iframe></div>');
	 }
	 else if(mask=='mask3')
	 {
		 $('body').append('<div id="'+mask+'"></div><div id="mask3in"><img id="mask_img" src="app_ask/view/images/dealing.gif"/><li>结果查询中</li><img id="mask_close_img" src="app_ask/view/images/close.gif" onclick=" __ask.closeWindow(\'mask3in\'); __ask.closeWindow(\'mask3\');" /></div>');
	 }
	var w = Math.max(document.documentElement.clientWidth ,document.body.clientWidth) + Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
	var h = Math.max(document.documentElement.clientHeight,document.body.clientHeight) +  Math.max(document.documentElement.scrollTop, document.body.scrollTop);
	w = Math.max(document.documentElement.scrollWidth,w);
	h = Math.max(document.documentElement.scrollHeight,h);
	$('#'+mask).css('height',h + 'px');
    $('#'+mask).css('width',w + 'px');
 }
 
 
 //-------------------------------------------
 //Confirm
 //-------------------------------------------
 AskControl.prototype.confirm = function()
 {
 }
  
 //-------------------------------------------
 //警告
 //-------------------------------------------
 AskControl.prototype.alert = function(alert_type,title,content,callback,width,height)
 {
	 if(title===undefined) title="警告";
	 if(content===undefined) content="";
	 if(width===undefined||width=='') width=350;
	 if(height===undefined) height=150;
	 if(callback===undefined) callback="";
	 var top = __ask.getScrollTop()+200;
	 if($('#alert').html()){__ask.closeWindow('alert');__ask.closeWindow('mask2');}
	 this.creat_mask('mask2');
	 $('body').append("<div id='alert'><div class='alert_title'><span class='alert_title_content'>"+title+"</span><a class='alert_close' onclick='"+callback+"__ask.closeWindow(\"alert\");__ask.closeWindow(\"mask2\");'>x</a></div><div id='"+alert_type+"_content'><br/>"+content+"</div><div style='width:100%; background:#f4f9ff; border-top:solid 1px #999;'><a class='alert_accept' onclick='"+callback+"__ask.closeWindow(\"alert\");__ask.closeWindow(\"mask2\");'></a></div></div>");
	 $('#alert').css('width',width+"px");
	 $('#alert').css('height',height+"px");
	 $('#'+alert_type+'_content').css('height',(height-80)+"px");
	 $('#alert').css('left',((window.screen.width-width)/2)+"px");
	 $('#alert').css('top',top+"px");
	 $("#alert").focus();
 }
 //-------------------------------------------
 //弹出窗口
 //-------------------------------------------
 AskControl.prototype.submit_ask = function(event)
 { 	 
 	 if(document.getElementById('dealing').style.display=='block')
	 {
		  __ask.alert('alert','警告','正在上传文件');
			 return false;
		  
		 }
	 else
	 {
		 var arr=this.gatherask();
		 if(arr.length<1)
		 {
			 __ask.alert('alert','警告','没有输入询价信息');
			 return false;
		 }
		 var asktype=$('#asktype').val();
		 if (asktype==2)
		 {
			 var project_name=trim($('#project_name').val());
			 var project_addr=trim($('#project_addr').val());
			 var project_process=$('#project_process').val();
			 if(project_name=='')
			 {
				 __ask.alert('alert','警告','没有输入工程名称');
				 return false;
				 }
				 if(project_addr=='')
			 {
				 __ask.alert('alert','警告','没有输入工程地点');
				 return false;
				 }
				 if(project_process=='')
			 {
				 __ask.alert('alert','警告','没有输入工程用途');
				 return false;
				 }
		 }
		 this.creat_mask('mask');
		/* if($('#pop_window').html()){__ask.alert('alert','警告','窗口已打开');return false;}
		$('body').append("<div class='pop_ask_window' id='pop_window' >载入中... <a href='javascript:void(0);' class='pop_window_op' onclick='__ask.getUserInfo()'>重试</a> <a href='javascript:void(0);' class='pop_window_op' onclick='__ask.closeWindow(\"pop_window\");__ask.closeWindow(\"mask2\");'>关闭</a></div>");*/
		$('#pop_window').css('display','block');
		$('#pop_window').css('z-index',150);
		$('#pop_window').css('left',385);
		$('#pop_window').css('top',260);
		 var asktitle=$('#asktitle').val();
	 var askarea=$('#askarea').find("option:selected").text(); 
	 var asktype=$('#asktype').find("option:selected").text(); 
	 var project_name=trim($('#project_name').val());
	 var project_addr=trim($('#project_addr').val());
	 var project_process=$('#project_process').find("option:selected").text(); 
	 var project_jiafang=trim($('#project_jiafang').val());
	 var project_shejiyuan=trim($('#project_shejiyuan').val());
	 var project_anzhuang=trim($('#project_anzhuang').val());
	 var attachment =$('#attachment').text(); 
	 var ask=$("input[id*=ask_]");
	 var ask_num_now=ask.length;
	 var arr=new Array();
	 for(var i=1;i<=ask_num_now;i++)
	 {
		 var ask_content=trim($('#ask_'+i).val());
		 if(ask_content=="") continue;
	     arr.push(ask_content);
		 if(asktitle=='')
		 {
			if(ask_content.length<6)
			{
				asktitle = '关于"'+ask_content+'"的询价';
			}
			else
			{
				asktitle = ask_content.substring(0,5)+'...';
				}
		 }
	 }
	 var content=arr.join('<br/>');
	 $('#ask_title').text(asktitle);
	 $('#ask_addr').text(askarea);
	 $('#ask_type').text(asktype);
	 if($('#asktype').val()==2)
	 {
		 $('#project_view').css('display','block');
		 $('#project_na').text(project_name);
		 $('#project_add').text(project_addr);
		 $('#project_type').text(project_process);
		 $('#project_inf').text(project_jiafang);
		 $('#project_des').text(project_shejiyuan);
		 $('#project_com').text(project_anzhuang);
		 }
	 $('#ask_att').text(attachment);
	 $('#ask_content').html(content);
		//this.getUserInfo();
	 }
 };

 //-------------------------------------------
//置顶弹出窗
//-------------------------------------------
 AskControl.prototype.setWindowTop = function()
 {
	$('#pop_window').css('z-index',++this.pop_max_index);
 };
 
//-------------------------------------------
//获取注册信息
//-------------------------------------------
 AskControl.prototype.getUserInfo = function()
 {

		
	$.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'ask',ac:'user_info'},
		   success:function(echo){
			   						   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else
			                           {
									   $('#pop_window').html(echo);__ask.getaskinfo();
									   }
		   },
		   error:function(){$('#pop_window').html('操作失败,请重试!');}
		   }); 
 };
  AskControl.prototype.getaskinfo = function()
  {
	  
	 var asktitle=$('#asktitle').val();
	 var askarea=$('#askarea').find("option:selected").text(); 
	 var asktype=$('#asktype').find("option:selected").text(); 
	 var project_name=trim($('#project_name').val());
	 var project_addr=trim($('#project_addr').val());
	 var project_process=$('#project_process').find("option:selected").text(); 
	 var project_jiafang=trim($('#project_jiafang').val());
	 var project_shejiyuan=trim($('#project_shejiyuan').val());
	 var project_anzhuang=trim($('#project_anzhuang').val());
	 var attachment =$('#attachment').text(); 
	 var ask=$("input[id*=ask_]");
	 var ask_num_now=ask.length;
	 var arr=new Array();
	 for(var i=1;i<=ask_num_now;i++)
	 {
		 var ask_content=trim($('#ask_'+i).val());
		 if(ask_content=="") continue;
	     arr.push(ask_content);
	 }
	 var content=arr.join(';');
	 $('#ask_title').text(asktitle);
	 $('#ask_addr').text(askarea);
	 $('#ask_type').text(asktype);
	 if($('#asktype').val()==2)
	 {
		 $('#project_view').css('display','block');
		 $('#project_na').text(project_name);
		 $('#project_add').text(project_addr);
		 $('#project_type').text(project_process);
		 $('#project_inf').text(project_jiafang);
		 $('#project_des').text(project_shejiyuan);
		 $('#project_com').text(project_anzhuang);
		 }
	 $('#ask_att').text(attachment);
	 $('#ask_content').text(content);
	 
	  }

 //-------------------------------------------
 //切换选项卡
 //-------------------------------------------
 AskControl.prototype.switch_menu = function(parent,val_id,val_num)
 {
	 
 }
 //切换teb
  AskControl.prototype.switchTab = function(tab_val,tab_num)
 { 
	 for(var i=1;i<tab_num+1;i++)
	 {
		if(i!=tab_val)
		{
		  $('#tab_'+i).attr("class","div_title_font");
		  $('#tab_content_'+i).css("display","none");
		}
		else
		{
		  $('#tab_'+i).attr("class","div_title_font li_active");
		  $('#tab_content_'+i).css("display","block");
		}
	 }
 };
 
 
 
 //-------------------------------------------
 //更改询价类型
 //-------------------------------------------
 AskControl.prototype.asktypechange = function()
 {
	 var checktext = $('#asktype').val();
	 if(checktext==2)
	 {
		 $('#project_info').css('display','block');
	 }
	 else
	 {
		 $('#project_info').css('display','none');
	 }
 }
 //-------------------------------------------
 //更改询价类型
 //-------------------------------------------
 AskControl.prototype.addask = function(num)
 {
	 var ask=$("input[id*=ask_]");
	 var ask_num_now=ask.length;
	 if(ask.length>=num)
	 {
		 __ask.alert('alert','提醒','已达到询价条数上限<br/><br/>如需帮助请您致电询价客服热线: <br />021-65377007*8007<br /><br /><span style=\'padding-left:100px;\'>信息中心</span>','','','220');
	 }
	 else
	 {
		 if(ask.length+5>=num)
		 {
             for (var i=ask_num_now+1;i<num+1;i++)
			 {
	             str = "<ul><li class=\"li_title\"><span>询价&nbsp;"+i+"：</span></li><li class=\"li_content\"><input type=\"text\" id=\"ask_"+i+"\" maxlength=\"45\" /></li></ul>";
	             $('#ask_'+parseInt(i-1)).parent().after(str);
			 }
		 }
		 else
		 {
             for (var i=ask_num_now+1;i<ask_num_now+6;i++)
			 {
	             str = "<ul><li class=\"li_title\"><span>询价&nbsp;"+i+"：</span></li><li class=\"li_content\"><input type=\"text\" id=\"ask_"+i+"\" maxlength=\"45\" /></li></ul>";
	             $('#ask_'+parseInt(i-1)).parent().after(str);
			 }
		 }
	 }
 }
 //-------------------------------------------
 //我要询价
 //-------------------------------------------
 AskControl.prototype.showask = function(id)
 {
	 if($('#'+id).text()=='>')
	 {
	 	$('#'+id).text('   ');
		 }
		 else
		 {
			 $('#'+id).text('>');
			 }
	 		 
	
 }
 //-------------------------------------------
 //后退
 //-------------------------------------------
 AskControl.prototype.historyback = function()
 {
	 history.back();
 }
 
  AskControl.prototype.historyback_page = function(back_page,back_pagesize)
 {
	 
	  window.location.href=document.referrer+'&page='+back_page+'&pagesize='+back_pagesize;
 }
 //-------------------------------------------
 //显示询价业务跟踪详情
 //-------------------------------------------
  AskControl.prototype.show_trace_detail = function(index)
 {	 
	 $('#ask_detail_'+index).css("display","block");
	 $('#ask_detail_show_'+index).html("<a href='javascript:void(0);' onclick=__ask.hide_trace_detail("+index+");><<详情</a>");
 }

 //-------------------------------------------
 //隐藏询价业务跟踪详情
 //-------------------------------------------
 AskControl.prototype.hide_trace_detail = function(index)
 { 
  	$('#ask_detail_'+index).css("display","none");
	$('#ask_detail_show_'+index).html("<a href='javascript:void(0);' onclick=__ask.show_trace_detail("+index+");>>>详情</a>");
 }
  //-------------------------------------------
 //显示询价进度
 //------------------------------------------- 
  AskControl.prototype.show_ask_schedule = function(ask_id)
 {
	 $('#tab_trace').attr("style","");
	$('#tab_schedule').css('background','url(./app_ask/view/images/div_title.gif)');
	$('#tab_schedule').css('color','#fff');
	$('#schedule').css("display","block");
	$('#trace').css("display","none");
 }
 
 //-------------------------------------------
 //显示询价跟踪
 //------------------------------------------- 
  AskControl.prototype.show_ask_trace= function(ask_id)
 {
	$('#tab_schedule').attr("style","");
	$('#tab_trace').css('background','url(./app_ask/view/images/div_title.gif)');
	$('#tab_trace').css('color','#fff');
	$('#schedule').css("display","none");
	$('#trace').css("display","block");
 }

 //-------------------------------------------
 //显示询价机器人
 //------------------------------------------- 
  AskControl.prototype.show_ask_robot = function(ask_id)
 {
	$('#tab_reply').attr("style","");
	$('#tab_robot').css('background','url(./app_ask/view/images/div_title.gif)');
	$('#tab_robot').css('color','#fff');
	$('#robot_reply').css("display","block");
	$('#ask_reply').css("display","none");
 }
 
 //-------------------------------------------
 //显示询价回复
 //------------------------------------------- 
  AskControl.prototype.show_askreply= function(ask_id)
 {
	$('#tab_robot').attr("style","");
	$('#tab_reply').css('background','url(./app_ask/view/images/div_title.gif)');
	$('#tab_reply').css('color','#fff');
	$('#robot_reply').css("display","none");
	$('#ask_reply').css("display","block");
 }
 
 
 //插入回复信息
  AskControl.prototype.save_reply= function(ask_id)
 {
	 var ask_id=ask_id;
	 var reply_content=trim($('#reply_content').val());
	 if(reply_content.length<5){__ask.alert('alert','警告','回复内容长度过短');return false;}
	 this.creat_mask('mask');
	 $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'ask',ac:'save_ask_reply',ask_id:ask_id,reply_content:reply_content},
		   success:function(echo){
			                          __ask.closeWindow("mask");
									   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo!='success')
									   {
										   __ask.alert('alert','错误','参数错误');
									   }
									   else
									   {
										   __ask.alert('ok','回复成功','询价回复成功','window.location.reload();');
									   }
								  },
		   error:function(){}
		   }); 
 }
  //插入评论信息
  AskControl.prototype.save_comment= function(ask_id)
 {
	 var ask_id=ask_id;
	 var comment_content=trim($('#comment_content').val());
	 var SpeedScore=$('#hidSpeedScore').val();
	 var QualityScore=$('#hidQualityScore').val();
	 if(SpeedScore==''||QualityScore==''){__ask.alert('alert','警告','请您选择星级评分');return false;}
	 this.creat_mask('mask');
	 $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'ask',ac:'save_ask_comment',ask_id:ask_id,comment_content:comment_content,SpeedScore:SpeedScore,QualityScore:QualityScore},
		   success:function(echo){
			                          __ask.closeWindow("mask");
									   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo!='success')
									   {
										   __ask.alert('alert','错误','参数错误');
									   }
									   else
									   {
										   __ask.alert('ok','成功','询价评论成功','window.location.reload();');
									   }
							     },
		   error:function(){}
		   });
 }
 
 //插入评论回复信息
 AskControl.prototype.save_comment_reply= function(ask_id)
 {
	 var ask_id=ask_id;
	 var comment_content_reply=trim($('#comment_content_reply').val());
	 if(comment_content_reply.length<5){__ask.alert('alert','警告','评论内容不少于5个字');return false;}
	 this.creat_mask('mask');
	 $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'ask',ac:'save_ask_comment_reply',ask_id:ask_id,comment_content_reply:comment_content_reply},
		   success:function(echo){
			                          __ask.closeWindow("mask");
									   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo!='success')
									   {
										   __ask.alert('alert','错误','参数错误');
									   }
									   else
									   {
										   __ask.alert('ok','成功','评论回复成功','window.location.reload();');
									   }},
		   error:function(){}
		   });
 }
 //-------------------------------------------
 //最近询价翻页
 //-------------------------------------------
  AskControl.prototype.get_recent_ask = function(page,pagesize)
  {
	  $('#recent_ask').html("<img src='./app_ask/view/images/loader.gif' class='loader' />");
	  $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'home',ac:'recent_ask',page:page,pagesize:pagesize},
		   success:function(echo){
									   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
			  						   else
									   {
										   $('#recent_ask').html(echo);}
		   							   },
		   error:function(){}
		   });
  }

 //-------------------------------------------
 //公告翻页
 //-------------------------------------------
  AskControl.prototype.get_notice_list = function(page,pagesize)
  {
	  $('#message_box_r').html("<img src='./app_ask/view/images/loader.gif' class='loader' />");
	  $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'message',ac:'get_notice_list',page:page,pagesize:pagesize},
		   success:function(echo){
			   						   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else
			   						   {
										   $('#message_box_r').html(echo);}
		   							   },
		   error:function(){}
		   });
  }
 //-------------------------------------------
 //我的询价翻页
 //-------------------------------------------
  AskControl.prototype.get_myasklist = function(page,pagesize)
  {
	  $('#my_ask_list').html("<img src='./app_ask/view/images/loader.gif' class='loader' />");
	  $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'ask',ac:'get_myasklist',page:page,pagesize:pagesize},
		   success:function(echo){
			   						   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else
									   {
										   $('#my_ask_list').html(echo);}
		   							    },
		   error:function(){}
		   });
  }
 //-------------------------------------------
 //所有询价翻页
 //-------------------------------------------
  AskControl.prototype.get_allasklist = function(page,pagesize)
  {
	  $('#allask_content').html("<img src='./app_ask/view/images/loader.gif' class='loader' />");
	  $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'ask',ac:'get_allasklist',page:page,pagesize:pagesize},
		   success:function(echo){
			  						   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   } 
			   						   else
									   {
										   $('#allask_content').html(echo);
									   }},
		   error:function(){}
		   });
  }
  //-------------------------------------------
 //收件箱翻页
 //-------------------------------------------
  AskControl.prototype.get_message_list = function(page,pagesize)
  {
	  $('#tab_content_1').html("<img src='./app_ask/view/images/loader.gif' class='loader' />");
	  $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'message',ac:'get_message_list',page:page,pagesize:pagesize},
		   success:function(echo){
			   						   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
			                           else
									   {
										   $('#tab_content_1').html(echo);}
		   							   },
		   error:function(){}
		   });
  }
  //-------------------------------------------
 //发件箱翻页
 //-------------------------------------------
  AskControl.prototype.get_messageout_list = function(page,pagesize)
  {
	  $('#tab_content_1').html("<img src='./app_ask/view/images/loader.gif' class='loader' />");
	  $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'message',ac:'get_messageout_list',page:page,pagesize:pagesize},
		   success:function(echo){
			   						   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else
									   {
										   $('#tab_content_1').html(echo);}
									   },
		   error:function(){}
		   });
  }
  //-------------------------------------------
 //询价回复翻页
 //-------------------------------------------
  AskControl.prototype.get_ask_reply = function(ask_id,page,pagesize)
  {
	  $('#ask_all_answer').html("<img src='./app_ask/view/images/loader.gif' class='loader' />");
	  $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'ask',ac:'get_ask_reply',ask_id:ask_id,page:page,pagesize:pagesize},
		   success:function(echo){
			   						   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else
									   {
										   $('#ask_all_answer').html(echo);}
									   },
		   error:function(){}
		   });
  }
  //-------------------------------------------
 //自助询价翻页
 //-------------------------------------------
  AskControl.prototype.get_fast_search = function(page,pagesize)
  {
	   var material_temp=$('#search_content_detail_material').val();
	  var brand_temp=$('#search_content_detail_brand').val();
	  var supplier_temp=$('#search_content_detail_supplier').val();
		
	  search_str=material_temp+brand_temp+supplier_temp;
	  $('#search_result').html("<img src='./app_ask/view/images/loader.gif' class='loader' />");
	  $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'search',ac:'fast_search',search_content_key:search_str,page:page,pagesize:pagesize},
		   success:function(echo){
			   						   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else
									   {
										   $('#search_result').html(echo);  $('#search_content_detail_material').val(material_temp);
										   $('#search_content_detail_brand').val(brand_temp);
										   $('#search_content_detail_supplier').val(supplier_temp);}
									   },
		   error:function(){}
		   });
  }
  
  
  
    AskControl.prototype.get_fast_search_detail = function(page,pagesize)
  {
	  	var category_search=$('#category_search').val();
	    var brand_search=$('#brand_search').val();
		
	  var material_temp=$('#search_content_detail_material').val();
	  var brand_temp=$('#search_content_detail_brand').val();
	  var supplier_temp=$('#search_content_detail_supplier').val();
		
	  search_str=material_temp+brand_temp+supplier_temp;
	  $('#ask_search_detail').html("<img src='./app_ask/view/images/loader.gif' class='loader' />");
	  $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'search',ac:'fast_search_detail',search_content_key:search_str,page:page,pagesize:pagesize,category_search:category_search,brand_search:brand_search},
		   success:function(echo){
			   						   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else
									   {
										   $('#ask_search_detail').html(echo);}
									   },
		   error:function(){}
		   });
  }
 //-------------------------------------------
 //checkbox全选
 //-------------------------------------------
  AskControl.prototype.checkAll = function()
  {
	var code_Values = document.getElementsByTagName("input"); 
	for(i = 0;i < code_Values.length;i++){ 
	if(code_Values[i].type == "checkbox") 
	{ 
	code_Values[i].checked = true; 
	} 
	} 
  }
 //-------------------------------------------
 //checkbox全不选
 //-------------------------------------------
  AskControl.prototype.uncheckAll = function()
  { 
	var code_Values = document.getElementsByTagName("input"); 
	for(i = 0;i < code_Values.length;i++){ 
	if(code_Values[i].type == "checkbox") 
	{ 
	code_Values[i].checked = false; 
	} 
	} 
  } 
  
 //-------------------------------------------
 //删除选中的意见反馈和站内信
 //-------------------------------------------
  AskControl.prototype.deleteSelected = function(message_type)
  { 
    if(message_type=='inbox')
	{
 	var advise_id_array=new Array();
	$(".checkbox_inbox").each(function(){	
	var val=$(this).val();
	if(this.checked){
	advise_id_array.push(val);
	}
	});
	if(advise_id_array==""){alert('请选择要删除的选项');return false;}
 	var advise_id_array=advise_id_array.join(','); 
	if(confirm('确定删除该信息？'))
	{
	 $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'message',ac:'update_advise_isdeleted',advise_id_array:advise_id_array},
		   success:function(echo){
			   			   			   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
			   						   else if(echo=="成功删除")
		   	   						   {
										   __ask.alert('alert','提示','删除成功','__ask.toUrl("'+__ask.appUrl+'&c=message&ac=messagebox");');
			   							   
			   						   }},
		   error:function(){}
		   }) 
	}
	}
	else if(message_type=='outbox')
	{
	var message_id_array=new Array();
	$(".checkbox_outbox").each(function(){	
	var val=$(this).val();
	if(this.checked){
	message_id_array.push(val);
	}
	});
	if(message_id_array==""){alert('请选择要删除的选项');return false;}
 	var message_id_array=message_id_array.join(','); 
	if(confirm('确定删除该信息？'))
	{
	 $.ajax({
		   type: "POST",
		   url:this.url,
		   data:{app:this.app,c:'message',ac:'update_message_isdeleted',message_id_array:message_id_array},
		   success:function(echo){
			   			   			   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
			   						   else if(echo=="成功删除")
		       						   {
										   __ask.alert('alert','提示','删除成功','__ask.toUrl("'+__ask.appUrl+'&c=message&ac=messagebox_outbox");');
									   }},
		   error:function(){}
		   }) 
	}
	}
	
  } //setSelectedRead
 //-------------------------------------------
 //设置选中的意见反馈和站内信已读
 //-------------------------------------------
 AskControl.prototype.setSelectedRead = function(message_type)
 {
	 if(message_type=='outbox')
	 {
		 	var message_id_array=new Array();
			$(".checkbox_outbox").each(function(){	
			var val=$(this).val();
			if(this.checked){
			message_id_array.push(val);
			}
			});
			if(message_id_array==""){alert('请选择要标记已读的选项');return false;}
 			var message_id_array=message_id_array.join(','); 
			$.ajax({
		    type: "POST",
		    url:this.url,
		    data:{app:this.app,c:'message',ac:'update_message_is_read',message_id_array:message_id_array},
		    success:function(echo){			   						  
									   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo=="成功标记已读")
			   						   {
										   __ask.alert('alert','提示','成功标记已读');
										   __ask.toUrl(__ask.appUrl+'&c=message&ac=messagebox_outbox')
									   }},
		    error:function(){}
		   }) 		 
	 }
	 else if(message_type=='inbox')
	 {
		 	var advise_id_array=new Array();
			$(".checkbox_inbox").each(function(){	
			var val=$(this).val();
			if(this.checked){
			advise_id_array.push(val);
			}
			});
			if(advise_id_array==""){alert('请选择要标记已读的选项');return false;}
 			var advise_id_array=advise_id_array.join(','); 
			$.ajax({
		    type: "POST",
		    url:this.url,
		    data:{app:this.app,c:'message',ac:'update_advise_is_read',advise_id_array:advise_id_array},
		    success:function(echo){
									   if(echo.indexOf('页面已经过期')>=0)
									   {
										   __ask.alert('alert','错误','页面过期,请重新登录','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo.indexOf('异地登录')>=0)
									   {
										   __ask.alert('alert','错误','系统检测到您的帐号在异地登录，您被迫下线！','__ask.toUrl("'+__ask.appUrl+'");');
									   }
									   else if(echo=="成功标记已读")
									   {
			   							   __ask.alert('alert','提示','成功标记已读');
			   							   __ask.toUrl(__ask.appUrl+'&c=message&ac=messagebox')
									   }},
		    error:function(){}
		   }) 		 
	 } 
 }

 //去掉字串右边的空格
function rTrim(str)
{
  var iLength;
  
  iLength = str.length;
  if (str.charAt(iLength - 1) == " ")
  {
    //如果字串右边第一个字符为空格
    str = str.slice(0, iLength - 1);//将空格从字串中去掉
    //这一句也可改成 str = str.substring(0, iLength - 1);
    str = rTrim(str);    //递归调用
  }
  return str;
}

//去掉字串两边的空格
function trim(str)
{
  return lTrim(rTrim(str));
}

function lTrim(str)
{
  if (str.charAt(0) == " ")
  {
    //如果字串左边第一个字符为空格
    str = str.slice(1);//将空格从字串中去掉
    //这一句也可改成 str = str.substring(1, str.length);
    str = lTrim(str);    //递归调用
  }
  return str;
}

 
var __ask=new AskControl();
 __ask.ini();
 
 

